﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Web_Pages_ReadMessageControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string username = ((Users)Session["User"]).Username.ToString();
        ReadMessage(username);
    }
    void ReadMessage(string username)
    {
        UsersBLL userBLL = new UsersBLL();
        
        Users user = userBLL.GetIUsers.GetUserByUsername(username);

        
        List<Messages> message = userBLL.GetIMessages.GetMessagessOfUser(user);


        DataList1.DataSource = message;


        CollectionPager1.MaxPages = 10;

        CollectionPager1.PageSize = 1; // số items hiển thị trên một trang

        CollectionPager1.DataSource = message;

        CollectionPager1.BindToControl = DataList1;

        DataList1.DataSource = CollectionPager1.DataSourcePaged;

        DataList1.DataBind();
    }

}